package Gui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JFrame;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class grafica extends JPanel  implements Runnable{

	int x = 0;
	int y = 0;

	private void moveBall() {
		x = x + 1;
		y = this.getWidth()/2;
	}

	@Override
	public void paint(Graphics g) {
		//super.paint(g);
		Graphics2D g2d = (Graphics2D) g;
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
		g2d.fillOval(x, y, 5, 5);
	}

	public grafica(){
		Dimension d = new Dimension();
		d.setSize(100, 100);
		this.setSize(d);
	}
	
	
	public static void main(String[] args) throws InterruptedException {
		JFrame frame = new JFrame("Mini Tennis");
		grafica game = new grafica();
		frame.add(game);
		
		frame.setSize(50,50);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		game.run();
	}

	@Override
	public void run() {
		while (true) {
			this.moveBall();
			this.repaint();
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		
	}
}